<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
	function check(){
		var $name = $("#empName").val(); //获取姓名
		var $bookManageAuthor = $("#dept").val();  //获取部门
		var $bookManageTime = $("#chkDate").val();//获取考勤日期
		
		var $option = $("select").val();  //获取下拉框
		if($name==null||$name == ""){
			alert("姓名不能为空");
			return false;
		}
		if ($bookManageAuthor == "") {
			alert("部门不能为空");
			return false;
		}
		//正则表达式
		var reg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;
		if(!reg.test($bookManageTime)){
		　　alert("日期格式不正确，正确格式为：2014-01-01");
		　　return false;
		}
		if($bookManageTime ==""){
			alert("考勤日期不能为空");
			return false;
		}
		if ($option==0) {
			alert("请选择考勤类型");
			return false;
		}
		return true;
	}
	</script>
	<div>
		<p style="text-align: center;">添加考勤记录信息</p>
		<form action="AttenceAdd" method="post" onsubmit="return check()">
			<table border="1" align="center">
				<tr>
					<td>姓名</td>
					<td><input type="text" id="empName" name="empName"></td>
				</tr>
				<tr>
					<td>所属部门</td>
					<td><input type="text" id="dept" name="dept"></td>
				</tr>
				<tr>
					<td>考勤日期</td>
					<td><input type="text" id="chkDate" name="chkDate">日期格式:yyyy-mm</td>
				</tr>
				<tr>
					<td>考勤状态</td>
					<td><select name="status">
							<option value="0">请选择考勤类型</option>
							<option value="1">正常</option>
							<option value="2">迟到</option>
							<option value="3">早退</option>
							<option value="4">休假</option>
							<option value="5">外出</option>
					</select></td>
				</tr>
				<tr>
					<th><input type="submit" value="登记"></th>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>